package org.hcyspartnoc.demo.common.core.context;


import lombok.ToString;
import org.hcyspartnoc.demo.pojo.po.system.SysUserPo;

import java.io.Serial;
import java.util.HashMap;
import java.util.Map;

@ToString
public class BaseContextImpl implements BaseContext {

    @Serial
    private static final long serialVersionUID = -6700739862432928044L;
    // 用户类
    private SysUserPo baseCurrentUser = new SysUserPo();
    // 变量
    private Map<Object, Object> properties = new HashMap<>();
    // 业务变量
    private Map<Object, Object> busiProperties = new HashMap<>();

    public BaseContextImpl() {
    }

    @Override
    public SysUserPo getBaseCurrentUser() {
        return this.baseCurrentUser;
    }

    @Override
    public void setBaseCurrentUser(SysUserPo baseCurrentUser) {
        this.baseCurrentUser = baseCurrentUser;
    }

    @Override
    public Object getProperty(Object var) {
        return this.properties.get(var);
    }

    @Override
    public void addProperty(Object varKey, Object varValue) {
        this.properties.put(varKey, varValue);
    }

    @Override
    public void removeProperty(Object var) {
        this.properties.remove(var);
    }

    @Override
    public Map<Object, Object> getProperties() {
        return this.properties;
    }

    @Override
    public void setProperties(Map<Object, Object> map) {
        this.properties = map;
    }

    @Override
    public void removeAllProperties() {
        this.properties.clear();
    }

    @Override
    public void addBusiProperty(Object busiVarKey, Object busiVarValue) {
        this.busiProperties.put(busiVarKey, busiVarValue);
    }

    @Override
    public Object getBusiProperty(Object busiVarKey) {
        return this.busiProperties.get(busiVarKey);
    }

    @Override
    public Map<Object, Object> getBusiProperties() {
        return this.busiProperties;
    }

    @Override
    public void setBusiProperties(Map<Object, Object> map) {
        this.busiProperties = map;
    }
}

